package com.hzcx.app.simplechat.ui.login.presenter;

import android.app.Activity;
import android.content.Context;

import com.hzcx.app.simplechat.api.BaseDialogObserver;
import com.hzcx.app.simplechat.base.BaseEmptyBean;
import com.hzcx.app.simplechat.base.BasePresenter;
import com.hzcx.app.simplechat.bean.UpLoadImgBean;
import com.hzcx.app.simplechat.model.LoginModel;
import com.hzcx.app.simplechat.model.PublicModel;
import com.hzcx.app.simplechat.model.UserModel;
import com.hzcx.app.simplechat.ui.login.bean.PhoneCityBean;
import com.hzcx.app.simplechat.ui.login.contract.AddUserInfoContract;
import com.hzcx.app.simplechat.ui.login.contract.PhoneCityContract;

import java.util.List;

public class AddUserInfoPresenter extends BasePresenter<AddUserInfoContract.View> implements AddUserInfoContract.Presenter {

    /**
     *  上传头像
     * @param context
     * @param path
     * @param token
     */
    @Override
    public void uploadImg(Activity context, String path, String token) {
        PublicModel.upLoadImg(context, token, path, new BaseDialogObserver<UpLoadImgBean>(context) {
            @Override
            protected void onSuccess(UpLoadImgBean data) {
                mView.uploadResult(data);
            }
        });
    }

    /**
     *  提交用户资料
     * @param context
     * @param token
     * @param avatar
     * @param nickname
     */
    @Override
    public void commitUserInfo(Context context, String token, String avatar, String nickname) {
        UserModel.updateUserInfo(context, token, avatar, nickname, new BaseDialogObserver<BaseEmptyBean>(context) {
            @Override
            protected void onSuccess(BaseEmptyBean data) {
                mView.commitSuccess();
            }
        });
    }
}
